#include <Felicia.h>

unsigned int number=0;
unsigned char symbol;

int main(void)
{
	//InitUSART();
	InitLED();
	InitKeyboard();
	InitTimer();
	sei();
	
	//flags|=(1<<COUNTER);
	flags|=(1<<KEYSCAN);
	flags|=(1<<LED_UPD);

	while(1)
	{
		if (flags&COUNTER)
		{
			flags&=~(1<<COUNTER);
			if (++number==1000) number=0;
			ConvertNum(number);
			SetTimer(COUNTER,1000);
		}

		if (flags&KEYSCAN)
		{
			flags&=~(1<<KEYSCAN);
			symbol=ScanKeyboard();
			ConvertChar(symbol);
			SetTimer(KEYSCAN,50);
		}

		if (flags&LED_UPD)
		{
			flags&=~(1<<LED_UPD);
			UpdateLED();
			SetTimer(LED_UPD,5);
		}
	}

	return 0;
}
